const { defineConfig } = require('@vue/cli-service');
const path=require("path");
const NodePolyfillPlugin =require("node-polyfill-webpack-plugin");

module.exports = defineConfig({
    transpileDependencies: true,
    css:{
		sourceMap:true
    },
	devServer:{
		open:true,
		host:"localhost",
		// port:"8080",
		https:false,
		client:{
			overlay:false
		},
		proxy:{
			"/qilin":{
				target:"https://www.qilin-web.cn",
				changeOrigin:true,
				pathRewrite:{
					"^/qilin":"/qilin"
				},
				logLevel:"debug" //打印请求日志
			}
		}
	},
	runtimeCompiler:true, //可以在组件化项目中使用template模板编译器
	configureWebpack:{
        resolve:{
            alias:{
                "@":path.resolve(__dirname,"src"),
                "$less":path.resolve(__dirname,"src/assets/less")
            }
        },
		plugins: [new NodePolyfillPlugin()]
    },
	chainWebpack:(config)=>{
        const oneOfsMap=config.module.rule("less").oneOfs.store;
        oneOfsMap.forEach((item)=>{
            item
                .use("style-resources-loader")
                .loader("style-resources-loader")
                .options({
					patterns:[
						path.resolve(__dirname,"./src/assets/less/common.less")
					]
                })
                .end()
        });
    }
});
